package com.ibiaoke.goods.dao;

import com.ibiaoke.common.base.BaseDao;
import com.ibiaoke.common.base.Page;
import com.ibiaoke.goods.entity.*;
import com.ibiaoke.goods.mapper.XcxReduceGoodsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class XcxReduceGoodsDao extends BaseDao<XcxReduceGoods, XcxReduceGoodsExample, Integer,XcxReduceGoodsMapper> {

    @Autowired
    private XcxReduceGoodsMapper xcxReduceGoodsMapper;

    @Override
    public XcxReduceGoodsMapper getMapper() {
        return xcxReduceGoodsMapper;
    }

    public List<XcxReduceGoods> findXcxReduceGoods(Integer shopId,Page page) {
        XcxReduceGoodsExample example = new XcxReduceGoodsExample();
        XcxReduceGoodsExample.Criteria criteria = example.createCriteria();
        if (shopId != null) {
            criteria.andShopIdEqualTo(shopId);
        }
        page.setTotalCount(xcxReduceGoodsMapper.countByExample(example));
        example.setLimitStart(page.limitStart());
        example.setLimitEnd(page.limitEnd());
        example.setOrderByClause("create_time desc");
        return xcxReduceGoodsMapper.selectByExample(example);
    }
}
